home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / libs / sphigs / sph_dos.lha / dos / sphsrc.v08 / sph_post.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-11-26  |  3.2 KB  |  114 lines

  1. #include "HEADERS.h"
  2. #include "sphigslocal.h"
  3.  
  4. #define PROPER_VIEW  SPH_viewTable[viewIndex]
  5.  
  6.  
  7. /** SPH_postRoot
  8. I make no attempt to verify that this very structure hasn't already
  9. been posted to this very view.
  10.  
  11. Strange thing: let's say that I post while regeneration is suppressed.
  12. And immediately obtain a pointer measure.  It would be possible for an
  13. object in the newly posted network to be "picked" via the correlation
  14. even though it has never appeared on the screen!
  15. **/
  16. void
  17. SPH_postRoot (structID, viewIndex)
  18. int structID, viewIndex;
  19. {
  20.    root_header *baby_network;
  21.  
  22.    SPH_check_system_state;
  23.    SPH_check_no_open_structure;
  24.    SPH_check_structure_id;
  25.    SPH_check_view_index;
  26.  
  27.    ALLOC_RECORDS (baby_network, root_header, 1);
  28.    baby_network->root_structID = structID;
  29.  
  30.    SPH__structureTable[structID].refcount++;
  31.  
  32.    /* ADD TO VIEW DATABASE: to have highest overlap in its own view's list */
  33.    baby_network->nextHigherOverlapRoot = NULL;
  34.    baby_network->nextLowerOverlapRoot = PROPER_VIEW.highestOverlapNetwork;
  35.    if (PROPER_VIEW.lowestOverlapNetwork == NULL)
  36.       PROPER_VIEW.lowestOverlapNetwork = baby_network;
  37.    else
  38.       PROPER_VIEW.highestOverlapNetwork->nextHigherOverlapRoot = baby_network;
  39.    PROPER_VIEW.highestOverlapNetwork = baby_network;
  40.  
  41.    VIEWOPT__afterNewPosting (&PROPER_VIEW, structID);
  42.    SPH__refresh_post (viewIndex);
  43. }
  44.  
  45.  
  46.  
  47. /*!*/
  48. void
  49. SPH_unpostRoot (structID, viewIndex)
  50. int structID, viewIndex;
  51. {
  52.    root_header *network_to_die;
  53.  
  54.  
  55.    SPH_check_system_state;
  56.    SPH_check_no_open_structure;
  57.    SPH_check_structure_id;
  58.    SPH_check_view_index;
  59.  
  60.    /* LOOK FOR THE ROOT HEADER BY SCANNING VIEW'S NETWORK LIST */
  61.    network_to_die = PROPER_VIEW.highestOverlapNetwork;
  62.    while (network_to_die->root_structID != structID) {
  63.       network_to_die = network_to_die->nextLowerOverlapRoot;
  64.       if (network_to_die == NULL)
  65.      SPH__error (ERR_UNPOST_NONEXTANT_ROOT);
  66.    }
  67.  
  68.    /* DELETE W/ HIGHER OVERLAPPERS */
  69.    if (network_to_die->nextHigherOverlapRoot == NULL)
  70.       PROPER_VIEW.highestOverlapNetwork = network_to_die->nextLowerOverlapRoot;
  71.    else
  72.       network_to_die->nextHigherOverlapRoot->nextLowerOverlapRoot =
  73.      network_to_die->nextLowerOverlapRoot;
  74.    /* DELETE W/ LOWER OVERLAPPERS */
  75.    if (network_to_die->nextLowerOverlapRoot == NULL)
  76.       PROPER_VIEW.lowestOverlapNetwork = network_to_die->nextHigherOverlapRoot;
  77.    else
  78.       network_to_die->nextLowerOverlapRoot->nextHigherOverlapRoot =
  79.      network_to_die->nextHigherOverlapRoot;
  80.  
  81.    SPH__structureTable[structID].refcount--;
  82.  
  83.    VIEWOPT__afterUnposting (&PROPER_VIEW, structID);
  84.    SPH__refresh_unpost (viewIndex);
  85.    
  86.    free (network_to_die);
  87. }
  88.  
  89.  
  90.  
  91. /*!*/
  92. void
  93. SPH_unpostAllRoots (int viewIndex)
  94. {
  95.    root_header *network_to_die, *next_network_to_die;
  96.  
  97.    SPH_check_system_state;
  98.    SPH_check_no_open_structure;
  99.    SPH_check_view_index;
  100.  
  101.    network_to_die = PROPER_VIEW.highestOverlapNetwork;
  102.    while (network_to_die != NULL) {
  103.       next_network_to_die = network_to_die->nextLowerOverlapRoot;
  104.       SPH__structureTable[network_to_die->root_structID].refcount--;
  105.       free (network_to_die);
  106.       network_to_die = next_network_to_die;
  107.    }
  108.    
  109.    PROPER_VIEW.highestOverlapNetwork = PROPER_VIEW.lowestOverlapNetwork = NULL;
  110.    
  111.    ClearBitstring (&(PROPER_VIEW.descendent_list));
  112.    SPH__refresh_unpost (viewIndex);
  113. }
  114.